﻿/*
{
"状态":1,
"名称":"修改-用户资料",
"作者":"陈泽椿",
"创建时间":"2018-06-30",
"功能":"修改-用户资料",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/
declare @user_key int ,@user_id varchar(100) , @user_name varchar(100) , @sex varchar(100)
declare @telphone varchar(100) ,@mobilephone varchar(100) , @address varchar(100)
set @user_key = '{user}'
set @user_id ='{user_id}' 
set @user_name = '{user_name}'
set @sex = '{sex}'
set @telphone ='{telphone}' 
set @mobilephone = '{mobilephone}'
set @address = '{address}'


--校验信息
if isnull(@user_id,'')=''
begin 
	RAISERROR ('SQL:用户id不允许为空', 16 ,1 ) ; 
	return 
end 

if isnull(@user_name,'')=''
begin 
	RAISERROR ('SQL:用户名称不允许为空', 16 ,1 ) ; 
	return 
end 

if EXISTS(SELECT * FROM y_user WHERE [user_key] <> @user_key and [user_id]=@user_id )
begin
	RAISERROR ('SQL:用户id已经存在', 16 ,1 ) ; 
	return 
end

update [dbo].[y_user] set
[user_id] = @user_id ,
[user_name] = @user_name ,
[simple_code] = dbo.f_getpy(@user_name),
[sex] = @sex , 
[telphone] = @telphone , 
[mobilephone] = @mobilephone , 
[address] = @address , 
[update_time] = getdate()
where [user_key] = @user_key